Dynamic Dashboards

Dynamic Dashboards give developers the ability to build and modify dashboards through code. You use Workspace Assemblies, which enhance the flexibility of your dashboards and reduce the time spent in the user interface. This enables you to build more of your solutions within Workspaces.

NOTE: Dynamic Dashboards should be created by developers.

Implementing Dynamic Dashboard Services

Dynamic Dashboard Services offer unique capabilities because unlike other service types, they do not have an equivalent in traditional Business Rules. Dynamic Dashboard Services provide additional connections in the loading mechanism of a dashboard, enabling developers to customize the dashboard and its components.

The most commonly implemented methods in a Dynamic Dashboard Service are GetEmbeddedDynamicDashboard and GetDynamicComponentsForDynamicDashboard.

Dynamic Dashboard Service Methods

GetEmbeddedDynamicDashboard

This method is run when you display an Embedded Dynamic Dashboard type or an Embedded Dynamic Repeater Dashboard type. The Dynamic Dashboard Service is returned by the Service Factory set in the Maintenance Unit or Workspace containing the dashboard. In the body of this function, developers can access or modify their properties and instantiate in memory all objects necessary to display the dashboard.

In the following example, users can load a dashboard that uses a certain border color by default and change it according to a user-specific property:

The code sample allows users to load a dashboard that uses a certain border color by default and change it according to a user-specific property

Copy
VB.Net Code
Public Function GetEmbeddedDynamicDashboard(ByVal si As SessionInfo, ByVal api As IWsasDynamicDashboardsApiV800, ByVal workspace As DashboardWorkspace, _
            ByVal maintUnit As DashboardMaintUnit, ByVal parentDynamicComponentEx As WsDynamicComponentEx, ByVal storedDashboard As Dashboard, _
            ByVal customSubstVarsAlreadyResolved As Dictionary(Of String, String)) As WsDynamicDashboardEx Implements IWsasDynamicDashboardsV800.GetEmbeddedDynamicDashboard
            Try
                If (api IsNot Nothing) Then
                       ' check on dashboard name to execute only when necessary
                    If storedDashboard.Name.XFEqualsIgnoreCase("My Embedded Dashboard") Then
                        ' create the dashboard in memory
                        Dim myDash As WsDynamicDashboardEx = api.GetEmbeddedDynamicDashboard(si, _
                        workspace, parentDynamicComponentEx, _
                        storedDashboard, String.Empty,Nothing, _
                        TriStateBool.Unknown, WsDynamicItemStateType.Unknown)
                        ' modify formatting if necessary 
                        If si.UserName.XFEqualsIgnoreCase("Richmond Avenal") Then
                            myDash.DynamicDashboard.DisplayFormat &= ", BorderColor = Black"
                        End If
                    End If    
                End If

                Return Nothing
            Catch ex As Exception
                Throw New XFException(si, ex)
            End Try
        End Function

Users can also create new Repeater items to generate a large number of new components on the page without having to set them up manually. See the use case in Service-based Dynamic Repeater.

The code sample displays how users can create new Repeater items to generate a large number of new components on the page without having to set them up manually

Copy
VB.Net Code
 Public Function GetEmbeddedDynamicDashboard(ByVal si As SessionInfo, ByVal api As IWsasDynamicDashboardsApiV800, ByVal workspace As DashboardWorkspace, _
            ByVal maintUnit As DashboardMaintUnit, ByVal parentDynamicComponentEx As WsDynamicComponentEx, ByVal storedDashboard As Dashboard, _
            ByVal customSubstVarsAlreadyResolved As Dictionary(Of String, String)) As WsDynamicDashboardEx Implements IWsasDynamicDashboardsV800.GetEmbeddedDynamicDashboard
            Try
                If (api IsNot Nothing) Then
                    ' check on dashboard name to execute only when necessary
                    If storedDashboard.Name.XFEqualsIgnoreCase("My Embedded Dashboard") Then
                    
                        ' get a list of users, and wrap them in repeatArgs
                        Dim users As List(Of UserSummaryInfo) = BRApi.Security.Admin.GetUsers(si)
                        Dim repeatArgs As New List(Of WsDynamicComponentRepeatArgs)
                        For Each user As UserSummaryInfo In users:
                            Dim nextLevelTemplateSubstVarsToAdd As New Dictionary(Of String, String) _
                                From {{"name",user.Name},{"description",user.Description}}
                                        repeatArgs.Add( _
                                            New WsDynamicComponentRepeatArgs( _
                                                user.UniqueID, nextLevelTemplateSubstVarsToAdd))
                        Next
                    
                        ' create the dashboard in memory
                        Dim myDash As WsDynamicDashboardEx = api.GetEmbeddedDynamicDashboard(si, _
                            workspace, parentDynamicComponentEx, _
                            storedDashboard, String.Empty,Nothing, _
                            TriStateBool.Unknown, WsDynamicItemStateType.Unknown)
                                                
                        ' Attach our List of repeaters. 
                        ' This is equivalent to populating property "Component Template Repeat Items" 
                        '    on the Dashboard
                            myDash.DynamicDashboard.Tag = repeatArgs
                        Return myDash
                        
                    Else
                        ' default behaviour for other dashboards
                        Return api.GetEmbeddedDynamicDashboard(si, _
                            workspace, parentDynamicComponentEx, _
                            storedDashboard, String.Empty,Nothing, _
                            TriStateBool.Unknown, WsDynamicItemStateType.Unknown)
                    End If

                End If

                Return Nothing
            Catch ex As Exception
                Throw New XFException(si, ex)
            End Try
        End Function

GetDynamicComponentsForDynamicDashboards

This method is run when a Dynamic Dashboard generates the necessary components in memory. Users can specify custom logic to modify the generated components rather than modifying the dashboard as a whole. GetEmbeddedDynamicDashboard and GetDynamicComponentsForDynamicDashboard are often coupled, particularly when using a Repeater configuration. GetEmbeddedDynamicDashboard sets up values for each iteration of the Repeater Template, and GetDynamicComponentsForDynamicDashboard uses these values to configure the repeated components.

For example, users may want to dynamically change an Embedded Component property to display a different Embedded Dashboard. Instead of having to use Parameters that reference Legacy Business Rules within the Maintenance Unit, users can use code in a Dynamic Dashboard Service. See the following example:

The code sample displays a way to  dynamically change an Embedded Component property to display a different Embedded Dashboard

Copy
VB.Net Code
Public Function GetDynamicComponentsForDynamicDashboard(ByVal si As SessionInfo, ByVal api As IWsasDynamicDashboardsApiV800, ByVal workspace As DashboardWorkspace, _
            ByVal maintUnit As DashboardMaintUnit, ByVal dynamicDashboardEx As WsDynamicDashboardEx, ByVal customSubstVarsAlreadyResolved As Dictionary(Of String, String)) _
            As WsDynamicComponentCollection Implements IWsasDynamicDashboardsV800.GetDynamicComponentsForDynamicDashboard
            Try
                If (api IsNot Nothing) Then
                    ' if we are executing the specific dashboard...
                    If dynamicDashboardEx.DynamicDashboard.Name.XFEqualsIgnoreCase("MyEmbeddedDashboard") Then
                    
                        ' first we create the components ...
                        Dim comps As WsDynamicComponentCollection = _
                        api.GetDynamicComponentsForDynamicDashboard(si, workspace, _
                        dynamicDashboardEx, String.Empty, Nothing, TriStateBool.Unknown, _
                        WsDynamicItemStateType.Unknown)
                        
                        ' ... then find the Embedded Component that we will manipulate …
                        Dim embComp As WsDynamicDbrdCompMemberEx = _
                        comps.GetComponentUsingBasedOnName("My Embedded Component")
                        
                        ' ... then make the change …
                        embComp.DynamicComponentEx.DynamicComponent.Component.EmbeddedDashboardName = _
                        dashboardName
                        ' ... and return all components!
                        Return comps
                    End If                    
                End If

                Return Nothing
            Catch ex As Exception
                Throw New XFException(si, ex)
            End Try
        End Function

These are the other methods implemented in a Dynamic Dashboard Service:

  • GetDynamicAdaptersForDynamicComponent

  • GetDynamicCubeViewForDynamicAdapter

  • GetDynamicParametersForDynamicComponent

  • GetDynamicCubeViewForDynamicComponent

These methods are similar to GetDynamicComponentsForDynamicDashboard. They are run when the relevant elements, such as Data Adapters and parameters, are created in memory. To implement these methods, instantiate the elements in memory with the relevant API method, modify them as necessary, and return them. For more information on these methods and their arguments, see API Reference.

Stored Components and Dynamic Components

A Stored Component is any item you create on the Workspaces page, such as a button component. Its configuration is saved in the database and used whenever the component is displayed in a dashboard. When a Stored Component is used in an Embedded Dynamic Dashboard or an Embedded Dynamic Repeater Dashboard, one or more Dynamic Component instances are created in memory. You can modify these instances in the Dynamic Dashboard Service to provide a customized experience without modifying the underlying Stored Component.

Stored Components are represented by traditional classes, such as DashboardComponent and DashboardParameter. Dynamic Components are represented by classes with a Ws prefix, like WsDynamicComponent and WsDynamicParameter.